function FollowUnfollow(param) {

	var that = this;
	
	this.j_follow_unfollow_link = null;

	var follow_url = "";
	var unfollow_url = "";
	
	var processing = false;
	
	var cur_follow_unfollow_link = null;
	
	function __construct(p) {
		for(pkey in p) {
			if(pkey[0] != "_") {
				that[pkey] = p[pkey];
			}
			if(p._follow_url) {
				follow_url = p._follow_url;
			}
			if(p._unfollow_url) {
				unfollow_url = p._unfollow_url;
			}
		}
		
		that.j_follow_unfollow_link.live('click', followOrUnfollowLinkClick);
	}
	
	function followOrUnfollowLinkClick(e) {
	try{
		e.preventDefault();
		if(!processing) {
			processing = true;
			cur_follow_unfollow_link = jq(this);
			var user_id = cur_follow_unfollow_link.data("user-id");
			if(cur_follow_unfollow_link.hasClass("follow")) {
				follow(user_id);
			} else if(cur_follow_unfollow_link.hasClass("following")) {
				unfollow(user_id);
			}
		}
	}catch(err) {
		alert(err);
	}
	}

	function follow(user_id) {
	try{
		jq.get(follow_url, { 'user_id' : user_id }, followSuccess)
	    .error(function() {
			var pos_top = cur_follow_unfollow_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Oops! An error occurred while processing your request." });
	    })
	    .complete(function() {
	   		// complete
	    	processing = false;
	    });
	}catch(err) {
		alert(err);
	}
	}
	
	function followSuccess(data) {
	try{
		if(data === "SUCCESS") {
			cur_follow_unfollow_link.removeClass("follow");
			cur_follow_unfollow_link.addClass("following");
		}else if(data === "UNAUTHORIZED") {
			var pos_top = cur_follow_unfollow_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Please login before attempting this operation." });
		}
	}catch(err) {
		alert(err);
	}
	}
	
	function unfollow(user_id) {
	try{
		jq.get(unfollow_url, { 'user_id' : user_id }, unfollowSuccess)
	    .error(function() {
			var pos_top = cur_follow_unfollow_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Oops! An error occurred while processing your request." });
	    })
	    .complete(function() {
	   		// complete
	    	processing = false;
	    });
	}catch(err) {
		alert(err);
	}
	}
	
	function unfollowSuccess(data) {
	try{
		if(data === "SUCCESS") {
			cur_follow_unfollow_link.removeClass("following");
			cur_follow_unfollow_link.addClass("follow");
		}else if(data === "UNAUTHORIZED") {
			var pos_top = cur_follow_unfollow_link.offset().top;
			jq.notification({ "pos_top" : pos_top, "width" : 360, "message" : "Please login before attempting this operation." });
		}
	}catch(err) {
		alert(err);
	}
	}
	
	__construct(param);
	
}
